package com.ruoyi.report.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.report.mapper.ReportSelfPickupCustomerMapper;
import com.ruoyi.report.domain.ReportSelfPickupCustomer;
import com.ruoyi.report.service.IReportSelfPickupCustomerService;

/**
 * 自提油客户管理Service业务层处理
 * 
 * @author scp
 * @date 2024-10-11
 */
@Service
public class ReportSelfPickupCustomerServiceImpl implements IReportSelfPickupCustomerService 
{
    @Autowired
    private ReportSelfPickupCustomerMapper reportSelfPickupCustomerMapper;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询自提油客户管理
     * 
     * @param id 自提油客户管理ID
     * @return 自提油客户管理
     */
    @Override
    public ReportSelfPickupCustomer selectReportSelfPickupCustomerById(Long id)
    {
        return reportSelfPickupCustomerMapper.selectReportSelfPickupCustomerById(id);
    }

    /**
     * 查询自提油客户管理列表
     * 
     * @param reportSelfPickupCustomer 自提油客户管理
     * @return 自提油客户管理
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<ReportSelfPickupCustomer> selectReportSelfPickupCustomerList(ReportSelfPickupCustomer reportSelfPickupCustomer)
    {
        return reportSelfPickupCustomerMapper.selectReportSelfPickupCustomerList(reportSelfPickupCustomer);
    }

    /**
     * 新增自提油客户管理
     * 
     * @param reportSelfPickupCustomer 自提油客户管理
     * @return 结果
     */
    @Override
    public int insertReportSelfPickupCustomer(ReportSelfPickupCustomer reportSelfPickupCustomer)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        reportSelfPickupCustomer.setCreateBy(loginUser.getUser().getUserName());
        reportSelfPickupCustomer.setDeptId(loginUser.getUser().getDeptId());
        reportSelfPickupCustomer.setCreateTime(DateUtils.getNowDate());
        return reportSelfPickupCustomerMapper.insertReportSelfPickupCustomer(reportSelfPickupCustomer);
    }

    /**
     * 修改自提油客户管理
     * 
     * @param reportSelfPickupCustomer 自提油客户管理
     * @return 结果
     */
    @Override
    public int updateReportSelfPickupCustomer(ReportSelfPickupCustomer reportSelfPickupCustomer)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        reportSelfPickupCustomer.setUpdateBy(loginUser.getUser().getUserName());
        reportSelfPickupCustomer.setUpdateTime(DateUtils.getNowDate());
        return reportSelfPickupCustomerMapper.updateReportSelfPickupCustomer(reportSelfPickupCustomer);
    }

    /**
     * 批量删除自提油客户管理
     * 
     * @param ids 需要删除的自提油客户管理ID
     * @return 结果
     */
    @Override
    public int deleteReportSelfPickupCustomerByIds(Long[] ids)
    {
        return reportSelfPickupCustomerMapper.deleteReportSelfPickupCustomerByIds(ids);
    }

    /**
     * 删除自提油客户管理信息
     * 
     * @param id 自提油客户管理ID
     * @return 结果
     */
    @Override
    public int deleteReportSelfPickupCustomerById(Long id)
    {
        return reportSelfPickupCustomerMapper.deleteReportSelfPickupCustomerById(id);
    }
}
